package com.demo.base.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 分页数据
 * @date 2023/3/13 2:54 PM
 */
@Setter
@Getter
@ApiModel(value = "PageData", description = "分页数据体")
public class PageData<T> {

    @ApiModelProperty(value = "页码")
    private Integer pageIndex = 1;

    @ApiModelProperty(value = "页大小")
    private Integer pageSize = 20;

    @ApiModelProperty(value = "总数")
    private int totalCount;

    @ApiModelProperty(value = "数据列表")
    private List<T> dataList = new ArrayList<>();

    public PageData(Integer pageIndex, Integer pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
    }

    public PageData(Integer pageIndex, Integer pageSize, int totalCount) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    public PageData(Integer pageIndex, Integer pageSize, List<T> dataList) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.dataList = dataList;
    }

    public PageData(Integer pageIndex, Integer pageSize, int totalCount, List<T> dataList) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.dataList = dataList;
    }
}
